<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<head>
    <title>Title</title>
</head>
<body>
欢迎${pageContext.request.session.getAttribute("userInfo").name}使用现在考试系统&nbsp;&nbsp;<a
        href="javascript:logOut({project_name:'${ctx}'});">注销</a>
试卷管理模块

<div id="exame_paper_list">

</div>
<script src="${ctx}/common/jquery/jquery-3.5.0.js"></script>
<script src="${ctx}/examination/common_module/js/sys_user.js"></script>
<script>
    //进行考试
    function testExamePaper(examePaperId){
        window.location.href="${ctx}/ExamePaperDetailServlet?methodName=testExamePaper&examePaperId="+examePaperId;
    }
    $(document).ready(function () {
        //方法跳转
        function getExamePaperList() {
            $.ajax({
                url: "${ctx}/ExamePaperDetailServlet?methodName=getExamePaperList",
                data: {},
                type: "post",
                success: function (result) {
                    // $("#div1").html(result);
                    // alert("ajax回调成功"+result);
                    // console.log(result);
                    debugger;
                    var state = result.state;
                    if (state == '200') {
                        var msg = result.msg;
                        var list = result.list;
                        var htmlStr = '';
                        htmlStr += '<table border="1">';
                        htmlStr += '    <tr>';
                        htmlStr += '        <td>测试题数量</td>';
                        htmlStr += '         <td>考试时间</td>';
                        htmlStr += '         <td>试卷分数</td>';
                        htmlStr += '         <td>操作</td>';
                        htmlStr += '    </tr>';
                        for (let i = 0; i < list.length; i++) {
                            var obj = list[i];
                            htmlStr += '    <tr>';
                            htmlStr += '        <td>'+obj.questionsTotal+'</td>';
                            htmlStr += '         <td>'+obj.testTime+'</td>';
                            htmlStr += '         <td>'+obj.totalGoal+'</td>';
                            htmlStr += '         <td><a href="javascript:testExamePaper('+obj.id+')">考试</a></td>';
                            htmlStr += '    </tr>';
                        }
                        htmlStr += '    </table>';
                        $("#exame_paper_list").html(htmlStr);
                    }
                }
            });
        }

        getExamePaperList();
    });
</script>
</body>
</html>
